package com.hsp.codeblock;

public class CodeBlockDetail04 {
    public static void main(String[] args) {
//        B02 b02 = new B02();
        new C02();
    }
}
class C02{
    public int n1 = 100;
    private static int n2=200;
    private  void m1(){
        System.out.println("m1");
    }
    private static void m2(){
        System.out.println("m2");
    }

    static {
        //静态代码块只能调用静态成员
        System.out.println(n2);
        C02.m2();
    }
    {//普通代码块可以调用所有的资源
        System.out.println(n1+n2);
        m1();
        m2();
    }
}


class A02{
    private static int n1= getVal01();
    static {
        System.out.println("A02 的一个静态代码块");//2
    }
    {
        System.out.println("A02 的一个普通代码块");//5
    }
    public int n3 = getVal02();
    public static int getVal01(){
        System.out.println("getVal01");//1
        return 10;
    }
    public int getVal02(){
        System.out.println("getVal02");//6
        return 10;
    }
    public A02(){
        System.out.println("A02的构造器");//7
    }
}
class B02 extends A02{
    private static int n3 = getVal03();
    static {
        System.out.println("B02 的一个静态代码块");//4
    }
    public int n5=getVal04();
    {
        System.out.println("B02 的一个普通代码块");//9
    }
    public static int getVal03(){
        System.out.println("getVal03");//3
        return 10;
    }
    public int getVal04(){
        System.out.println("getVal04");//8
        return 10;
    }
    public B02(){
        System.out.println("B02的构造器");//10
    }
}

